/*    */ package com.umeng.analytics.a;
/*    */ 
/*    */ import android.content.Context;
/*    */ import android.content.SharedPreferences;
/*    */ import android.content.SharedPreferences.Editor;
/*    */ import android.content.pm.ApplicationInfo;
/*    */ import com.umeng.analytics.j;
/*    */ import com.umeng.common.Log;
/*    */ import java.lang.reflect.Method;
/*    */ import org.json.JSONObject;
/*    */ 
/*    */ public class p
/*    */   implements g
/*    */ {
/* 20 */   public long a = 0L;
/* 21 */   public long b = 0L;
/*    */   private static final String c = "uptr";
/*    */   private static final String d = "dntr";
/*    */ 
/*    */   public void a(JSONObject paramJSONObject)
/*    */     throws Exception
/*    */   {
/* 30 */     if (paramJSONObject == null) return;
/*    */ 
/* 32 */     if (paramJSONObject.has("uptr")) this.a = paramJSONObject.getLong("uptr");
/* 33 */     if (paramJSONObject.has("dntr")) this.b = paramJSONObject.getLong("dntr"); 
/*    */   }
/*    */ 
/*    */   public void b(JSONObject paramJSONObject)
/*    */     throws Exception
/*    */   {
/* 38 */     if (this.a > 0L) paramJSONObject.put("uptr", this.a);
/* 39 */     if (this.b > 0L) paramJSONObject.put("dntr", this.b);
/*    */   }
/*    */ 
/*    */   public boolean a()
/*    */   {
/* 44 */     if ((this.a <= 0L) || (this.b <= 0L)) {
/* 45 */       return false;
/*    */     }
/* 47 */     return true;
/*    */   }
/*    */ 
/*    */   public static p a(Context paramContext) {
/*    */     try {
/* 52 */       p localp = new p();
/*    */ 
/* 54 */       long[] arrayOfLong = b(paramContext);
/*    */ 
/* 56 */       if ((arrayOfLong[0] <= 0L) || (arrayOfLong[1] <= 0L)) return null;
/*    */ 
/* 58 */       SharedPreferences localSharedPreferences = j.e(paramContext);
/*    */ 
/* 60 */       long l1 = localSharedPreferences.getLong("uptr", -1L);
/* 61 */       long l2 = localSharedPreferences.getLong("dntr", -1L);
/* 62 */       localSharedPreferences.edit().putLong("uptr", arrayOfLong[1])
/* 63 */         .putLong("dntr", arrayOfLong[0])
/* 64 */         .commit();
/*    */ 
/* 66 */       if ((l1 <= 0L) || (l2 <= 0L)) return null;
/*    */ 
/* 68 */       arrayOfLong[0] -= l2;
/* 69 */       arrayOfLong[1] -= l1;
/*    */ 
/* 71 */       if ((arrayOfLong[0] <= 0L) || (arrayOfLong[1] <= 0L)) return null;
/*    */ 
/* 73 */       localp.b = arrayOfLong[0];
/* 74 */       localp.a = arrayOfLong[1];
/*    */ 
/* 76 */       return localp;
/*    */     } catch (Exception localException) {
/* 78 */       Log.e("MobclickAgent", "sdk less than 2.2 has get no traffic");
/*    */     }
/* 80 */     return null;
/*    */   }
/*    */ 
/*    */   private static long[] b(Context paramContext) throws Exception {
/* 84 */     Class localClass = Class.forName("android.net.TrafficStats");
/* 85 */     Method localMethod1 = localClass.getMethod("getUidRxBytes", new Class[] { Integer.TYPE });
/* 86 */     Method localMethod2 = localClass.getMethod("getUidTxBytes", new Class[] { Integer.TYPE });
/*    */ 
/* 88 */     int i = paramContext.getApplicationInfo().uid;
/*    */ 
/* 90 */     if (i == -1) return null;
/*    */ 
/* 92 */     long[] arrayOfLong = new long[2];
/* 93 */     arrayOfLong[0] = ((Long)localMethod1.invoke(null, new Object[] { Integer.valueOf(i) })).longValue();
/* 94 */     arrayOfLong[1] = ((Long)localMethod2.invoke(null, new Object[] { Integer.valueOf(i) })).longValue();
/*    */ 
/* 96 */     return arrayOfLong;
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\umeng_sdk.jar
 * Qualified Name:     com.umeng.analytics.a.p
 * JD-Core Version:    0.6.2
 */